﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <LinearGradientBrush x:Key="SelectedTabItemBorderBrush" Opacity="0.75">
        <GradientStop Color="#00FFFFFF" Offset="0"/>
        <GradientStop Color="#FFFFFFFF" Offset="1"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="TabItemBorderBrush" Opacity="0.25">
        <GradientStop Color="#00FFFFFF" Offset="0"/>
        <GradientStop Color="#FFFFFFFF" Offset="1"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SelectedTabItemBackgroundBrush" Opacity="0.75">
        <GradientStop Color="#005B4411" Offset="0"/>
        <GradientStop Color="#FF5B4411" Offset="1"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="TabItemBackgroundBrush" Opacity="0.15">
        <GradientStop Color="#005B4411" Offset="0"/>
        <GradientStop Color="#FF5B4411" Offset="1"/>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="TabItemForeground" Color="White" />

    <Style TargetType="{x:Type TabItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid>
                        <Border Name="Border" Background="{StaticResource TabItemBackgroundBrush}"
                                        BorderBrush="{StaticResource TabItemBorderBrush}" BorderThickness="0,1,0,1"
                                        Opacity="0.5">
                            <ContentPresenter x:Name="ContentSite" VerticalAlignment="Center"
                                                      HorizontalAlignment="Center"
                                                      ContentSource="Header" Margin="12,2,12,2"
                                                      TextBlock.FontWeight="Bold"
                                                      TextBlock.Foreground="{StaticResource TabItemForeground}"
                                                      RecognizesAccessKey="True">
                            </ContentPresenter>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Panel.ZIndex" Value="100" />
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource SelectedTabItemBackgroundBrush}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource SelectedTabItemBorderBrush}" />
                            <Setter TargetName="Border" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Border" Property="Background" Value="White" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource TabItemBorderBrush}" />
                            <Setter Property="Foreground" Value="DarkGray" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <LinearGradientBrush x:Key="TabControlContentBackground" Opacity="0.25" StartPoint="0,0" EndPoint="0,1" >
        <GradientStop Color="#FF5B4411" Offset="0.9"/>
        <GradientStop Color="#A05B4411" Offset="1"/>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="TabControlContentForeground" Color="White" />

    <Style TargetType="{x:Type TabControl}">
        <Setter Property="TabStripPlacement" Value="Left" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="Padding" Value="2" />
        <Setter Property="Background" Value="{StaticResource TabControlContentBackground}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid ClipToBounds="True" SnapsToDevicePixels="True" KeyboardNavigation.TabNavigation="Local">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Name="ColumnDefinition0" />
                            <ColumnDefinition Width="0" Name="ColumnDefinition1" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" Name="RowDefinition0" />
                            <RowDefinition Height="*" Name="RowDefinition1" />
                        </Grid.RowDefinitions>

                        <Border x:Name="HeaderBorder" Background="Transparent">
                            <TabPanel IsItemsHost="True" Grid.Row="0" Grid.Column="0"
                                              Name="HeaderPanel" 
                                              Panel.ZIndex="1" 
                                              KeyboardNavigation.TabIndex="1" />
                        </Border>

                        <Grid Name="ContentPanel" Grid.Row="1" Grid.Column="0"
                                      KeyboardNavigation.TabIndex="2" 
                                      KeyboardNavigation.TabNavigation="Local" 
                                      KeyboardNavigation.DirectionalNavigation="Contained">
                            <Border Background="{TemplateBinding Background}"
                                            CornerRadius="0" Padding="5">
                                <ContentPresenter Content="{TemplateBinding SelectedContent}" 
                                                  ContentTemplate="{TemplateBinding SelectedContentTemplate}" 
                                                  ContentStringFormat="{TemplateBinding SelectedContentStringFormat}" 
                                                  ContentSource="SelectedContent" 
                                                  Name="PART_SelectedContentHost"
                                                  SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                            </Border>
                        </Grid>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="TabControl.TabStripPlacement" Value="Bottom">
                            <Setter TargetName="HeaderPanel" Property="Grid.Row" Value="1" />
                            <Setter TargetName="ContentPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="RowDefinition0" Property="RowDefinition.Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="RowDefinition.Height" Value="Auto" />
                            <Setter TargetName="HeaderBorder" Property="FrameworkElement.Margin" Value="0,0,0,0" />
                        </Trigger>
                        <Trigger Property="TabControl.TabStripPlacement" Value="Left">
                            <Setter TargetName="HeaderPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="ContentPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="HeaderPanel" Property="Grid.Column" Value="0" />
                            <Setter TargetName="ContentPanel" Property="Grid.Column" Value="1" />
                            <Setter TargetName="ColumnDefinition0" Property="ColumnDefinition.Width" Value="Auto" />
                            <Setter TargetName="ColumnDefinition1" Property="ColumnDefinition.Width" Value="*" />
                            <Setter TargetName="RowDefinition0" Property="RowDefinition.Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="RowDefinition.Height" Value="0" />
                            <Setter TargetName="HeaderBorder" Property="FrameworkElement.Margin" Value="0,0,0,0" />
                        </Trigger>
                        <Trigger Property="TabControl.TabStripPlacement" Value="Right">
                            <Setter TargetName="HeaderPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="ContentPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="HeaderPanel" Property="Grid.Column" Value="1" />
                            <Setter TargetName="ContentPanel" Property="Grid.Column" Value="0" />
                            <Setter TargetName="ColumnDefinition0" Property="ColumnDefinition.Width" Value="*" />
                            <Setter TargetName="ColumnDefinition1" Property="ColumnDefinition.Width" Value="Auto" />
                            <Setter TargetName="RowDefinition0" Property="RowDefinition.Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="RowDefinition.Height" Value="0" />
                            <Setter TargetName="HeaderBorder" Property="FrameworkElement.Margin" Value="0,0,0,0" />
                        </Trigger>
                        <Trigger Property="UIElement.IsEnabled" Value="False">
                            <Setter Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>